<!DOCTYPE html>
<html>
    
    <script type="text/javascript">
        function callJsAlert() {
            alert('Objective-C call js to show alert');
            
            window.webkit.messageHandlers.AppModel.postMessage({body: 'call js alert in js'});
        }
    
    
    function abc() {
        
    }
    </script>
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf8">
            <script language="javascript">
                
                var strhref = window.location.href;
                
                
                //JS执行window.webkit.messageHandlers.Share.postMessage(<messageBody>)
                function shareClick() {
                    window.webkit.messageHandlers.alipay.postMessage({sign:'biz_content=%7b%22timeout_express%22%3a%2230m%22%2c%22out_trade_no%22%3a%221216113103853207542%22%2c%22subject%22%3a%22%e4%b8%80%e5%85%83%e8%b4%ad%e8%ae%a2%e5%8d%95%22%2c%22total_amount%22%3a%220.01%22%2c%22body%22%3a%22%e4%b8%80%e5%85%83%e8%b4%ad%e8%ae%a2%e5%8d%95%22%7d&method=alipay.trade.app.pay&version=1.0&app_id=2016030601188528&format=json&timestamp=2016-12-16+11%3a31%3a03&sign_type=RSA&charset=utf-8&notify_url=http%3a%2f%2fyungou.ie1e.com%2fapp%2fpaynotify.aspx&sign=uvVwmSqs%2fUvlhRejXfLcwXeQZX0FOk%2bgepGvAESgXka7cwPW%2bGKE%2f1Xu06miGhcruV182vDHJxJLEMl1ZJhpP1XlVXUe%2fTmsLsRhlfr%2fQW%2fY4Q94KtZRVsHUDGCHDvhbWyWfOCC4ieitSxBufotbqhjf%2bERr51mGoy%2bvj%2bPMysw%3d'});
                }
            
            
            //JS执行window.webkit.messageHandlers.Camera.postMessage(<messageBody>)
            function payClick() {
                window.webkit.messageHandlers.jj.postMessage();
            }
            
            function QQShare() {
                window.webkit.messageHandlers.qqshare.postMessage(null);
            }
            
            //
            function callJsAlert(param) {
                window.webkit.messageHandlers.AppModel.postMessage({body: param});
            }
            
            
            function logout() {
                window.webkit.messageHandlers.gotoCart.postMessage(null);
            }
            
            function login() {
                <!--                window.webkit.messageHandlers.login.postMessage('首页');-->
                <!--                window.webkit.messageHandlers.login.postMessage('ss');-->
                window.webkit.messageHandlers.login.postMessage(strhref);
                
            }
            
            //跳转
            function jump() {
                //ios
                window.webkit.messageHandlers.jj.postMessage();
            }
            
                </script>
            </head>
    
    <body>
        <h1>这是按钮调用</h1>
        <input type="button" value="支付宝分享" onclick="shareClick()" />
        <input type="button" value="微信支付" onclick="payClick()" />
        
        <!--        <input type="button" value="QQ分享" onclick="QQShare()" />-->
        
        <input type="button" value="跳转" onclick="gotoCart()" />
        <input type="button" value="登陆" onclick="login()" />
        
        
        <div><input type="button" value="call js alert" onclick="callJsAlert()"></div>
        
    </body>
</html>
